package com.bjpoweernode;



import com.bjpoweernode.ba01.Student;
import com.bjpoweernode.ba02.School;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;


public class MyTest02 {

    @Test
    public void test01(){

        String config ="ba01/applicationContext.xml";


        ApplicationContext context = new ClassPathXmlApplicationContext(config);
        Object myStudent = context.getBean("myStudent");
        System.out.println(myStudent);

    }


    @Test
    public void test02(){
        System.out.println("+++++test02+++++");

        Student student= new Student();
        student.setAge(11);
        student.setName("lisi");

        School school= new School();
        school.setName("beijidaxue");
        student.setSchool(school);
        System.out.println(student);

    }
    //自动注入不需要使用ref= value= 赋值
    //自动注入autowire="byName"
    @Test
    public void test03(){
        ApplicationContext context=
                new ClassPathXmlApplicationContext("ba01/applicationContext.xml");
        Object myStudent1 = context.getBean("myStudent1");
        System.out.println(myStudent1);
    }
    //自动注入autowire="byType"
    @Test
    public void test04(){
        ApplicationContext context=
                new ClassPathXmlApplicationContext("ba01/applicationContext.xml");
        Object myStudent1 = context.getBean("myStudent2");
        System.out.println(myStudent1);
    }



}
